package com.andnnl.solon.actions;

import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.core.handle.ModelAndView;
import org.noear.solon.extend.data.annotation.Cache;
import org.noear.solon.extend.data.annotation.CacheRemove;
import org.noear.solon.extend.data.annotation.Tran;
import org.noear.solon.extend.validation.annotation.NotZero;

/**
 * Created by chenss on 2021/3/9.
 */
@Controller
public class DemoController {

    @Mapping("/")
    public String index(String u_u) {
        return "welcome222222!~";
    }


    //for http
    @Mapping("/hallo/{u_u}")
    public ModelAndView hallo(String u_u) {
        ModelAndView hallo = new ModelAndView("hallo.ftl");
        hallo.put("message",u_u);
        return hallo;
    }

    /*
    //for web socket （需添加：solon.boot.websocket 插件）
    @Mapping(value="/hallo/{u_u}", method = MethodType.WEBSOCKET)
    public ModelAndView hallo_ws(String u_u){
        return new ModelAndView("hallo");
    }
    */


    /*@Db
    BaseMapper<UserModel> userService;

    @NotZero("user_id")
    @CacheRemove(tags = "user_${user_id}")
    @Tran
    @Mapping("/user/update")
    public void udpUser(int user_id, UserModel user){
        userService.updateById(user);
    }

    @NotZero("user_id")
    @Cache(tags = "user_${user_id}")
    public UserModel getUser(int user_id){
        return userService.selectById(user_id);
    }*/

}
